package two_xia.ex8.Demo01;

public class Mainframe { //外观类：主机箱
    // 外观类组合各个硬件
    private Memory memory;
    private CPU cpu;
    private HardDisk harddisk;
    private OS windows;

    public Mainframe() {
        memory = new Memory();
        cpu = new CPU();
        harddisk = new HardDisk();
        windows = new OS();
    }

    public void on() {
        try { //调用各个子系统的业务方法完成电脑开机操作
            memory.check();
            cpu.run();
            harddisk.read();
            windows.load();
            System.out.println("启动成功！正在开机！");
        } catch (Exception e) {
            System.out.println("启动失败！！！");
        }
    }
}